
package com.tencent.weibo.api
{
	import com.tencent.weibo.log.LevelLogger;
	import com.tencent.weibo.operation.IRequestOperation;
	
	import mx.logging.ILogger;
	
	/**
	 * 邀请相关
	 * @langversion 3.0
	 * @playerversion Flash 9
	 * @playerversion AIR 1.1
	 *
	 */
	public class Invite extends AbstractAPI
	{
		/**
		 * 日志输出对象
		 */
		public static var logger:ILogger=LevelLogger.getLogger("com.tencent.weibo.api.Invite");
		/**
		 * 1.获取好友列表
		 * @param appid 应用的id
		 * @return IRequestOperation实例
		 */
		public function getInviteList(appid:String):IRequestOperation
		{
			checkAccessToken();
			var url:String = config.urlBase+"invite/get_invite_list";
			var attachParms:Object = {};
			attachParms.appid = appid;
			return generateDataRequest(url,attachParms,config.requestMethod);
		}
		/**
		 * 2.发送好友邀请
		 * @param appid 应用id
		 * @param appname 应用名
		 * @param content 邀请的内容(不能超过60字)
		 * @param names 邀请的好友账户列表，从get_invite_list接口获取,以","分隔，如abc,bcd(可选)
		 * @param fopenids 邀请的好友openid列表，从get_invite_list接口获取，以"_"分隔，如xxx_xxx(可选), names和fopenids至少选一个，若同时存在则以names值为主
		 * @param appCustom 回调url参数，与names或fopenids个数匹配，以","分隔（可选）
		 * @param clientip 用户的请求IP，必填
		 * @return IRequestOperation实例
		 */
		public function eventInvite(appid:String,appname:String,content:String,names:String=null,fopenids:String=null,appCustom:String=null,clientip:String="127.0.0.1"):IRequestOperation
		{
			checkAccessToken();
			var url:String = config.urlBase+"invite/event_invite";
			var attachParms:Object = {};
			attachParms.appid = appid;
			attachParms.appname = appname;
			attachParms.content = content;
			if(names != null)
				attachParms.names = names;
			if(fopenids != null)
				attachParms.fopenids = fopenids;
			if(appCustom != null)
				attachParms.app_custom = appCustom;
			attachParms.clientip = clientip;
			return generateDataRequest(url,attachParms,"POST");
		}
	}
}